import router from '@/router'

router.beforeEach(async(to, from, next) => {
  if (localStorage.getItem('token')) {
    console.log('11111');
    if (to.path === '/login') {
      console.log('11111');
      next('/')
    } else {
      next()
    }
  } else {
    if (to.path === '/login' || to.path === '/Home' || to.path === '/user') {
      console.log('2222');
      next()
    } else {
      next('/login')
    }
  }
})
